package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppTripFriend;
import com.vf.admin.miaodong.entity.AppUser;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * <p>Title : </p>
 * <p>Description : </p>
 * <p>DevelopTools : IDEA</p>
 * <p>DevelopSystem : Windows11</p>
 *
 * @Author : zxw
 * @Date 2023/8/31 11:10
 */
@Repository
public class AppTripFriendDao extends BaseDao<AppTripFriend> {

    public void save(AppTripFriend param) {
        if (param.getId() != null && param.getId() > 0) {
            this.update(param);
        } else {
            param.setId(this.add(param));
        }
    }

    public List<AppTripFriend> list(Map<String, Object> paraMap, SplitPageBean splitPageBean) {

        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder(" SELECT * FROM app_trip_friend WHERE 1=1 ");
        if (StringEx.isNotNull(paraMap.get("sex"))) {
            sbStr.append(" and sex = ? ");
            paramList.add(paraMap.get("sex"));
        }
        if (paraMap.containsKey("ids") && StringEx.isNotNull(paraMap.get("ids"))) {
            sbStr.append(" and id in (  ");
            sbStr.append(paraMap.get("ids"));
            sbStr.append(" ) ");
        }
        String sql = sbStr.toString();
        return this.queryList(sql, paramList, AppTripFriend.class, splitPageBean);
    }
}
